import fetch from 'common/src/utils/fetch'
//获取列表
export function getLeaveStudentList(data) {
    return fetch({
        url: '/api/studentservice/studentdeparture/departureList',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    })
}
//批量离校
export function batchLeaveSchool(data) {
    return fetch({
        url: '/api/studentservice/studentdeparture/departure',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    })
}
//导出
export function exportLeaveStudentList(data = {}) {
    // let keys = Object.keys(data).filter(item => data[item]);
    let keys = Object.keys(data).map(item => {return item;});
    let params = keys.reduce((prev, curr, index) => {
        prev += curr + '=' + data[curr];
        if (index < keys.length - 1) {
            prev += '&';
        }
        return prev;
    }, '');
    let url = '/api/studentservice/studentdeparture/exportDepartureList';
    params && (url += `?${params}`);
    window.open(url);
}
//撤销
export function revertStudent(data = {}) {
    return fetch({
        url: `/api/studentservice/studentdeparture/deDeparture`,
        method: 'post',
        data,
        headers: { 'Content-Type': 'application/json' }
    })
}
//自动离校
export function autoDeparture(data) {
    return fetch({
        url: '/api/studentservice/studentdeparture/autoDeparture',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    })
}
//获取详情
export function getLeaveStudentDetail(data = {}) {
    return fetch({
        url: `/api/studentservice/studentdeparture/departureDetail?studentId=${data.studentId}`,
        method: 'get',
        headers: { 'Content-Type': 'application/json' }
    })
}

// 离校日志管理查询
export function getLeaveLogList(data = {}) {
    return fetch({
        url: '/api/studentservice/studentdeparture/departureLog',
        method: 'post',
        data
    })
}

// 导出离校日志
export function exportLeaveLogList(data = {}) {
    // let keys = Object.keys(data).filter(item => data[item]);
    let keys = Object.keys(data).map(item => {return item;});
    let params = keys.reduce((prev, curr, index) => {
        prev += curr + '=' + data[curr];
        if (index < keys.length - 1) {
            prev += '&';
        }
        return prev;
    }, '');
    let url = '/api/studentservice/studentdeparture/exportDepartureLog';
    params && (url += `?${params}`);
    window.open(url);
}